/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.h
  * @brief          : Header for main.c file.
  *                   This file contains the common defines of the application.
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2024 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32f1xx_hal.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "adc.h"
#include "dma.h"
#include "tim.h"
#include "usart.h"
#include "gpio.h"
#include "stm32f1xx_it.h"

#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <math.h>

/* USER CODE END Includes */

/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */
typedef enum{
    LED_SATE_OFF = 0,
    LED_SATE_ON = 1,
}LED_SATE_ENUM;
/* USER CODE END ET */

/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */

/* USER CODE END EC */

/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */

/* USER CODE END EM */

/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);

/* USER CODE BEGIN EFP */

/* USER CODE END EFP */

/* Private defines -----------------------------------------------------------*/
#define LED_BUS_Pin GPIO_PIN_13
#define LED_BUS_GPIO_Port GPIOC
#define LED_MCU_Pin GPIO_PIN_14
#define LED_MCU_GPIO_Port GPIOC
#define DI3_Pin GPIO_PIN_1
#define DI3_GPIO_Port GPIOA
#define DI2_Pin GPIO_PIN_2
#define DI2_GPIO_Port GPIOA
#define DI1_Pin GPIO_PIN_3
#define DI1_GPIO_Port GPIOA
#define DI6_Pin GPIO_PIN_6
#define DI6_GPIO_Port GPIOA
#define DI5_Pin GPIO_PIN_10
#define DI5_GPIO_Port GPIOB
#define BUS_BUSY_Pin GPIO_PIN_8
#define BUS_BUSY_GPIO_Port GPIOA
#define DI4_Pin GPIO_PIN_3
#define DI4_GPIO_Port GPIOB
#define DI7_Pin GPIO_PIN_4
#define DI7_GPIO_Port GPIOB
#define DI8_Pin GPIO_PIN_5
#define DI8_GPIO_Port GPIOB
#define INT_Pin GPIO_PIN_9
#define INT_GPIO_Port GPIOB

/* USER CODE BEGIN Private defines */

#define LED_BUS_SET(_STATE_) do{(_STATE_==LED_SATE_ON)?(LED_BUS_GPIO_Port->BRR=LED_BUS_Pin):(LED_BUS_GPIO_Port->BSRR=LED_BUS_Pin);}while(0)
#define LED_BUS_GET ((LED_BUS_GPIO_Port->ODR&LED_BUS_Pin)?LED_SATE_OFF:LED_SATE_ON)
#define LED_MCU_SET(_STATE_) do{(_STATE_==LED_SATE_ON)?(LED_MCU_GPIO_Port->BRR=LED_MCU_Pin):(LED_MCU_GPIO_Port->BSRR=LED_MCU_Pin);}while(0)
#define LED_MCU_GET ((LED_MCU_GPIO_Port->ODR&LED_MCU_Pin)?LED_SATE_OFF:LED_SATE_ON)

float Get_Bus_Alp(void);
bool Get_GPIO_Port(uint8_t _gpio);
uint8_t Get_GPIO_Ports(void);
void gpio6_get_pulse(float* Frequency,float* Compare);
/* USER CODE END Private defines */

#ifdef __cplusplus
}
#endif

#endif /* __MAIN_H */
